﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Text;
using System.Net;
using System.IO;

///  
/// Mobmsg 的摘要说明 
///  
public class Mobmsg
{
    private string _MobNum;
    private string _MobMsg;
    public Mobmsg()
    {
        // 
        // TODO: 在此处添加构造函数逻辑 
        // 
    }
    public Mobmsg(string MobNum, string MobMsg)
    {
        this._MobNum = MobNum;
        this._MobMsg = MobMsg;
    }
    public void SendMsg()
    {
        ToMobile();
        
    }
    public void ToMobile()
    {//移动的接口 
        Encoding encoding = Encoding.GetEncoding("gb2312");
        string enterpriseid = "72326";//企业代码 
        string accountid = "10657001072326";
        string pwd = "ebest123";
        string postData = "enterpriseid=" + enterpriseid + "&accountid=" + accountid + "&pswd=" + pwd + "&mobs=" + this._MobNum + "&msg=" + this._MobMsg;
        string strUrl = "http://211.136.163.68:8000/httpserver";
        byte[] data = encoding.GetBytes(postData);
        // 准备请求... 
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrl);
        myRequest.Method = "POST";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.ContentLength = data.Length;
        Stream newStream = myRequest.GetRequestStream();
        // 发送数据 
        newStream.Write(data, 0, data.Length);
        newStream.Close();

        Stream stream = myRequest.GetResponse().GetResponseStream();

        data = new Byte[512];
        int i= stream.Read(data, 0, data.Length);
        string str = UTF8Encoding.UTF8.GetString(data, 0,i);
    }

    public bool CheckType(string MobileNum)
    {
        string ForeStr = MobileNum.Substring(0, 3);
        int ForeNum = Convert.ToInt32(ForeStr);
        if (ForeNum <= 134)
            return false;
        else
            return true;
    }
   
}